Except where otherwise noted, this content is Copyright (c) 2020, RTE and licensed under a CC-BY-4.0 license.

Begin Stochastic

What is a stochastic study ?

When you want to simulate a network adequacy, you can perform a deterministic computation. That means you believe you won’t have too much fluky behavior in the future. If you perform adequacy for the next hour or day, it’s a good hypothesis. But if you simulate network for the next week, month or year, it’s sound curious.

Are you sur wind will blow next week or sun will shines ? If not, you eolian or solar production could change. Can you warrant that no failure will occur on your network next month or next year ?

Of course, we can not predict future with such precision. It’s why we use stochastic computation. Stochastic means there are fluky behavior in the physics we want simulate. An single simulation is quiet useless, if result can change due to little variation.

The best solution could be to compute a God function which tell you for each input variation (solar production, line, consumptions) what is the adequacy result. Like that, Hadar has just to analyze function, its derivatives, min, max, etc to predict future. But this God function doesn’t exist, we just have an algorithm which tell us adequacy according to one fixed set of input data.

It’s why we use Monte Carlo algorithm. Monte Carlo run many scenarios to analyze many different behavior. Scenario with more consumption in cities, less solar production, less coal production or one line deleted due to crash. By this method we recreate God function by sampling it with the Monte-Carlo method.

Describe example

We will reuse network seen in Network Investment. If you don’t read this part, don’t worry we just reuse network no more. It’s look like

We use data generated in the next topic Workflow. Input data representes 10 scenarios with different load and eolien productions. There are also random faults for nuclear and gas. These 10 scenarios are unique. They are 10 random sampling on the God function to try to predict more widely network adequacy

import hadar as hd
import numpy as np
def read_csv(name):
    return np.genfromtxt('%s.csv' % name, delimiter=' ').T
line = 2000
study = hd.Study(horizon=168, nb_scn=10)\
    .network()\
        .node('a')\
            .consumption(name='load', cost=10**6, quantity=read_csv('load_A'))\
            .production(name='gas', cost=80, quantity=read_csv('gas'))\
        .node('b').consumption(name='load', cost=10**6, quantity=read_csv('load_B'))\
        .node('c').production(name='nuclear', cost=50, quantity=read_csv('nuclear'))\
        .node('d')\
            .consumption(name='load', cost=10**6, quantity=read_csv('load_D'))\
            .production(name='eolien', cost=20, quantity=read_csv('eolien'))\
        .link(src='a', dest='b', cost=5, quantity=line)\
        .link(src='b', dest='c', cost=5, quantity=line)\
        .link(src='c', dest='a', cost=5, quantity=line)\
        .link(src='c', dest='b', cost=10, quantity=line)\
        .link(src='c', dest='d', cost=10, quantity=line)\
        .link(src='d', dest='c', cost=10, quantity=line)\
    .build()
optimizer = hd.LPOptimizer()
res = optimizer.solve(study)
agg = hd.ResultAnalyzer(study, res)
plot = hd.HTMLPlotting(agg=agg, unit_symbol='MW', time_start='2020-06-19', time_end='2020-06-27',
                      node_coord={'a': [1.6264, 47.8842], 'b': [1.9061, 47.9118], 'c': [1.6175, 47.7097], 'd': [1.9314, 47.7090]})

Let’s start by a quick overview of adequacy by plotting a remain available capacity. Blue squares mean network as enough energy to sustain consumption. Red square mean network has a lack of adequacy.

plot.network().rac_matrix()

As you see it, stochastic is important. Some scenario like 5th is completly success. But if there are more consumption and less production due to unpredictable event, you will have unadequacy.

plot.network().node('b').consumption('load').timeline()
plot.network().node(node='b').stack(scn=7)

Hadar can also display valuable information about production. For examples, gas plan seems turn off most of the time

plot.network().node('a').production('gas').monotone(scn=7)
plot.network().node('d').production('eolien').timeline()

Then we can plot map to see exchange inside network

plot.network().map(t=4, scn=7, zoom=1.6)